package admin

import (
	"github.com/gorilla/mux"
	"net/http"
	"net/http/pprof"
)

func registerPProf(api *mux.Router) {
	api.HandleFunc("/debug/pprof/", pprof.Index)
	api.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
	api.HandleFunc("/debug/pprof/profile", pprof.Profile)
	api.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
	api.HandleFunc("/debug/pprof/trace", pprof.Trace)
	api.HandleFunc("/debug/pprof/allocs", func(writer http.ResponseWriter, request *http.Request) {
		r := pprof.Handler("allocs")
		r.ServeHTTP(writer, request)
	})

	api.HandleFunc("/debug/pprof/heap", func(writer http.ResponseWriter, request *http.Request) {
		r := pprof.Handler("heap")
		r.ServeHTTP(writer, request)
	})

	api.HandleFunc("/debug/pprof/goroutine", func(writer http.ResponseWriter, request *http.Request) {
		r := pprof.Handler("goroutine")
		r.ServeHTTP(writer, request)
	})
	//
	//prefixRouter.GET("/allocs", gin.WrapH(pprof.Handler("allocs")))
	//prefixRouter.GET("/block", gin.WrapH(pprof.Handler("block")))
	//prefixRouter.GET("/goroutine", gin.WrapH(pprof.Handler("goroutine")))
	//prefixRouter.GET("/heap", gin.WrapH(pprof.Handler("heap")))
	//prefixRouter.GET("/mutex", gin.WrapH(pprof.Handler("mutex")))
	//prefixRouter.GET("/threadcreate", gin.WrapH(pprof.Handler("threadcreate")))
}
